import com.alibaba.druid.pool.DruidDataSource;
import com.dfbz.model.Favorite;
import com.dfbz.model.User;
import com.dfbz.model.Userfocus;
import com.dfbz.service.*;
import com.dfbz.service.impl.*;
import org.junit.Test;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;

import java.util.List;
import java.util.Map;
import java.util.Properties;
public class testJDBC {
    @Test
    public void test() throws Exception{
//        DruidDataSource dataSource = new DruidDataSource();
//        Properties properties = new Properties();
//        properties.load(this.getClass().getClassLoader().getResourceAsStream("jdbc.properties"));
//        dataSource.setUsername(properties.getProperty("jdbc.username"));
//        dataSource.setPassword(properties.getProperty("jdbc.password"));
//        dataSource.setUrl(properties.getProperty("jdbc.url"));
//        dataSource.setDriverClassName(properties.getProperty("jdbc.driverClassName"));
//        JdbcTemplate template = new JdbcTemplate(dataSource);
//        List<User> list = template.query("select * from user", new BeanPropertyRowMapper<>(User.class));
//        for (User user:list) {
//            System.out.println(user);
//        }
//        UserServiceImpl userService = new UserServiceImpl();
//        User user = new User();
//        user.setId(24);
//        user.setUsername("aaa");
//        user.setPassword("bbb");
//        user.setEmail("100");
//        userService.register(user);
//        DeptService deptService=new DeptServiceImpl();
//        List<Map<String, Object>> all = deptService.findAll();
//        System.out.println(all);
//        User user=new User();
//        user.setId(222);
//        //user.setUsername("abc");
//        user.setPassword("csssc");
       UserService service=new UserServiceImpl();
//        service.update(user);
        //UserfocusService userfocusService=new UserfocusServiceImpl();
        //Userfocus userfocus=new Userfocus();
//        userfocus.setUserId(1);
////        userfocus.setUserFocusId(17);
////        userfocusService.save(userfocus);
        //userfocusService.deleteFocus(1,17);
        //List<User> users = service.findfocusAll(1);
        //System.out.println(users);
        FavoriteService favoriteService=new FavoriteServiceImpl();
        ArticleService articleService=new ArticleServiceImpl();
//        Favorite favorite=new Favorite();
//        favorite.setUId(1);
//        favorite.setAId(3);
//        favoriteService.save(favorite);
        Integer favorites = articleService.IsfavArticle(1, 4);
        System.out.println(favorites);
    }
}
